﻿Public Class DatVe

    Private Sub DatVe_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed

    End Sub

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Dim pdc As New DTO.PhieuDatCho
        pdc._cmnd = tb_cmnd.Text
        pdc._maChuyenBay = tb_machuyenbay.Text
        pdc._maHangVe = cbb_hangve.SelectedValue
        pdc._dienThoai = tb_dienthoai.Text
        pdc._tenHanhKhach = tb_tenhanhkhach.Text
        If Not Integer.TryParse(tb_giave.Text, pdc._gia) Then
            MessageBox.Show("Giá phải là số nguyên")
        End If



    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f_timchuyenbay As New DatVe_ChuyenBay(Me)
        f_timchuyenbay.ShowDialog()
    End Sub

    Private Sub rb_hanhkhachdamuave_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rb_hanhkhachdamuave.CheckedChanged
        bt_kiemtrathongtin.Visible = rb_hanhkhachdamuave.Checked
        tb_tenhanhkhach.ReadOnly = rb_hanhkhachdamuave.Checked
        tb_dienthoai.ReadOnly = rb_hanhkhachdamuave.Checked
    End Sub

    Private Sub bt_kiemtrathongtin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_kiemtrathongtin.Click
        If String.IsNullOrEmpty(tb_cmnd.Text) Then
            MessageBox.Show("Chưa nhập số chứng minh nhân dân của hành khách", "Đặt vé", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Else

            Dim hanhkhach As DTO.EditHanhKhach
            Dim bus_hanhkhach As New BUS.EditHanhKhach
            hanhkhach = bus_hanhkhach.lay_thong_tin_hanh_khach(tb_cmnd.Text)
            If IsNothing(hanhkhach) Then
                MessageBox.Show("Không tìm thấy hành khách có CMND là " + tb_cmnd.Text, "Đặt vé", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return
            End If

            tb_dienthoai.Text = hanhkhach.dienthoai
            tb_tenhanhkhach.Text = hanhkhach.hoten

        End If
    End Sub

    Private Sub tb_machuyenbay_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_machuyenbay.TextChanged
        If String.IsNullOrEmpty(tb_machuyenbay.Text) Then

        Else

        End If
    End Sub

End Class